Python 3 - Fun with Python String
This post some useful tips of using strings, and some issues while dealing with…
April 18, 2018
Listing down the commonly used Elastic Search queries.
GET /_cat/indices?v
GET INDEX_NAME/_search
{
"query": {
"match_all": {}
}
}
GET INDEX_NAME/TYPE_NAME/_search
{
"query": {
"match_all": {}
}
}
PUT INDEX_NAME/TYPE_NAME/6
{
"name": "name2",
"createdAt": "2017-07-27T08:38:48.276Z"
}
DELETE INDEX_NAME/TYPE_NAME/ID
GET INDEX_NAME/TYPE_NAME/_search
{
"query": {
"match_all": {}
},
"_source": ["ATTRIBUTE_NAME1", "ATTRIBUTE_NAME2"]
}
You can get search results within two dates specified.
Assuming: createdAt is the attribute which has date of creation of document.
Here,
gte means, greater than or equal to
lte means, less than or equal to
GET INDEX_NAME/TYPE_NAME/_search
{
"query": {
"range": {
"createdAt": {
"gte": "24/07/2017-13/02/12",
"lte": "26/07/2017-15/02/05",
"format": "dd/MM/yyyy-HH/mm/ss"
}
}
}
}
You have number of records. When you search by a unique identifier, you get all of them. But, in many cases, you might be needing only latest one or last few records.
GET INDEX_NAME/TYPE_NAME/_search
{
"query": {
"match": {
"NAME_ATTRIBUTE": "My identifier for name attribute"
}
},
"size": 10,
"sort": [
{
"createdAt": {
"order": "desc"
}
}
]
}
Above code will give 10 records of criteria mentioned. If I need only latest one record. I need to mention size to 1.
GET INDEX_NAME/TYPE_NAME/_search
{
"query": {
"match": {
"NAME_ATTRIBUTE": "My identifier for name attribute"
}
},
"size": 1,
"sort": [
{
"createdAt": {
"order": "desc"
}
}
]
}
GET INDEX_NAME/TYPE_NAME/_search
{
"query": {
"match": {
"data.key": "My value"
}
}
}
GET INDEX_NAME/TYPE_NAME/_search
{
"query": {
"match": {
"data.key": "My value"
}
},
"size": 1,
"sort": [
{
"createdAt": {
"order": "desc"
}
}
]
}
DELETE INDEX_NAME/TYPE_NAME/
DELETE INDEX_NAME
You want to search for all the documents where this particular attribute is not present.
Note: I’m not talking about its value. Just presence.
GET /index_name/type_name/_search
{
"query" : {
"bool": {
"must_not": [
{ "exists": { "field": "data.attrs.syncIssue" }}
]
}
}
}
This post some useful tips of using strings, and some issues while dealing with…
Assuming you have a java project and is using Visual Studio Code as IDE. All of…
Introduction In this tutorial we will see, How to list and download storage…
Introduction I had to develop a small automation to query some old mysql data…
Introduction There are some cases, where I need another git repository while…
Introduction In this guide, We will learn on how to create some handy command…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…